#include <stdio.h>

#include "beep.h"
#include "iot_gpio.h"
#include "iot_gpio_ex.h"
#include "iot_pwm.h"
#include "iot_errno.h"

#define IOT_PWM_PORT_PWM0   0

uint32_t Beep_Init(void)
{
    IoTGpioInit(IOT_IO_NAME_GPIO_9);
    IoSetFunc(IOT_IO_NAME_GPIO_9,IOT_IO_FUNC_GPIO_9_PWM0_OUT);
    IoTGpioSetDir(IOT_IO_NAME_GPIO_9, IOT_GPIO_DIR_OUT);
    IoTPwmInit(IOT_PWM_PORT_PWM0);
    return IOT_SUCCESS;
}

uint32_t Beep_On(void)
{
    IoTPwmStart(IOT_PWM_PORT_PWM0, 50, 4000);
    return IOT_SUCCESS;
}

uint32_t Beep_Off(void)
{
    IoTPwmStop(IOT_PWM_PORT_PWM0);
    return IOT_SUCCESS;
}
